import tkinter as tk
import pyautogui

class MouseTracker:
    def __init__(self, root):
        self.root = root
        self.root.title("Mouse Tracker")
        self.root.attributes('-topmost', True)

        self.label1 = tk.Label(self.root, text="X:")
        self.label1.pack()

        self.label2 = tk.Label(self.root, text="Y:")
        self.label2.pack()

        self.root.bind("<Button-1>", self.fix_position)
        self.root.bind("<Button-3>", self.continue_tracking)

        self.fixed = False

    def track_mouse(self):
        if not self.fixed:
            x, y = pyautogui.position()
            self.label1.config(text="X: " + str(x))
            self.label2.config(text="Y: " + str(y))
            self.root.after(100, self.track_mouse)

    def fix_position(self, event):
        self.fixed = True

    def continue_tracking(self, event):
        self.fixed = False

if __name__ == "__main__":
    root = tk.Tk()
    app = MouseTracker(root)
    app.track_mouse()
    root.mainloop()